<?php



namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Support\Facades\Log;

class WechatScanEvent implements  ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public string $code;




    /**
     * WechatScanEvent constructor.
     * @param string $code
     */
    public function __construct(string  $code)
    {

        $this->code = $code;

    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     *
     * @codeCoverageIgnore
     */
    public function broadcastOn()
    {
        $channelName = 'wechat_scan_' . $this->code;

        return new Channel($channelName);
    }

    /**
     * @return string
     */
    public function broadcastAs()
    {
        return 'WechatScanEvent';
    }
}
